package com.koron.css2.serviceManage.mapper;

import com.koron.css2.serviceManage.bean.BusinessAreaBean;
import com.koron.css2.serviceManage.queryBean.BusinessAreaQueryBean;
import com.koron.css2.serviceManage.vo.BusinessAreaVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.koron.ebs.mybatis.EnvSource;

import java.util.List;
import java.util.Map;

@EnvSource("_default")
public interface BusinessAreaMapper {

    Integer insertBusinessArea(BusinessAreaBean bean);

    List<BusinessAreaVo> selectBusinessAreaList(BusinessAreaQueryBean bean);

    @Select("select * from pub_business_area where id =#{id}")
    BusinessAreaBean findBusinessAreaInfoById(@Param("id") String id);

    Integer updateBusinessArea(BusinessAreaBean bean);
    /**
     * 校验字段内容重复
     */
    @Select("select count(*) from pub_business_area where ${key} = #{val}")
    Integer check(@Param("key") String key, @Param("val") String val);

    /**
     * 校验字段内容重复-排除当前记录
     */
    @Select("select count(*) from pub_business_area where ${key} = #{val} and id <> #{id}")
    Integer check2(@Param("key") String key, @Param("val") String val, @Param("id") String id);

    @MapKey("id")
    Map<String, Map> getNameAndId();
}
